﻿/**********************************弘石
*******************************************
* 功能描述:系统设置（机构设置）
* 作者:李兰祥
* 时间:2021‎年‎12‎月‎23日
* 
**********************************弘石
********************************************/
using HongStone.Domain.AttendanceManagement;
using HongStone.Domain.SystemSetupModel.AuthorityManagement;
using HongStone.Domain.SystemSetupModel.FrequentlyUsedDataModel;
using HongStone.Domain.SystemSetupModel.InstitutionSettingModel;
using HongStone.Ince;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HongStone.API.Controllers
{
    [ApiExplorerSettings(GroupName = "Setting")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SettingController : ControllerBase
    {
        private readonly InstitutionalSettingInce _app;
        public SettingController(InstitutionalSettingInce app)
        {
            _app = app;
        }

        /// <summary>
        /// 分页显示,查询(部门管理)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <param name="DeptName"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetDepartments(int pageIndex=1, int pageSize=2, string DeptName="")
        {
            var totalCount = 0;
            var list = _app.GetDepartments(pageIndex, pageSize, ref totalCount, DeptName);
            return Ok(new { list, totalCount });
        }

        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddDepartment(Department model)
        {
            return Ok(_app.AddDepartment(model));
        }

        /// <summary>
        /// 批量删除(部门管理)
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DeleteDepartment(string ids)
        {
            return Ok(_app.DeleteDepartment(ids));
        }

        /// <summary>
        /// 反填获取数据(部门管理)
        /// </summary>
        /// <param name="DeptId"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult EditDepartment(int DeptId)
        {
            return Ok(_app.EditDepartment(DeptId));
        }

        /// <summary>
        /// 修改(部门管理)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateDepartment(Department model)
        {
            return Ok(_app.UpdateDepartment(model));
        }

        /// <summary>
        /// 修改状态(显示)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateDepartment01(int DicTableId)
        {
            return Ok(_app.UpdateDepartment01(DicTableId));
        }

        /// <summary>
        /// 修改状态(隐藏)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateDepartment02(int DicTableId)
        {
            return Ok(_app.UpdateDepartment02(DicTableId));
        }

        /// <summary>
        /// 提醒管理
        /// </summary>
        /// <param name="BuName"></param>
        /// <param name="Name"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetReminders(string BuName="", string Name="", int pageIndex=1, int pageSize=2)
        {
            var totalCount = 0;
            var list = _app.GetReminders(BuName, Name, pageIndex, pageSize, ref totalCount);

            return Ok(new { totalCount, list });
        }

        /// <summary>
        ///显示权限（模块权限设置）
        /// </summary>
        /// <param name="ModuleGrade"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFuntion(string ModuleGrade)
        {
            return Ok(_app.GetFuntion(ModuleGrade));
        }

        /// <summary>
        /// 添加模块（模块权限设置）
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Add(Function model)
        {
            return Ok(_app.Add(model));
        }

        /// <summary>
        /// 反填模块（模块权限设置）
        /// </summary>
        /// <param name="ModuleId"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFunctions(string ModuleId)
        {
            return Ok(_app.GetFunctions(ModuleId));
        }

        /// <summary>
        /// 修改模块（模块权限设置）
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public IActionResult UpdateFuntion(Function model)
        {
            return Ok(_app.UpdateFuntion(model));
        }

        /// <summary>
        /// 删除模块（模块权限设置）
        /// </summary>
        /// <param name="ModuleId"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DeleteFunctions(string ModuleId)
        {
            return Ok(_app.DeleteFunctions(ModuleId));
        }

        /// <summary>
        /// 功能权限设置显示
        /// </summary>
        /// <param name="ModuleGrade"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFunction_Roles(string ModuleGrade="")
        {
            return Ok(_app.GetFunction_Roles(ModuleGrade));
        }

        /// <summary>
        /// 显示角色
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetRoleAdministrators()
        {
            return Ok(_app.GetRoleAdministrators());
        }

        /// <summary>
        /// 添加权限（添加功能权限）
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddFunction_Role(Function_Role model)
        {
            return Ok(_app.AddFunction_Role(model));
        }

        /// <summary>
        /// 反填(功能权限)
        /// </summary>
        /// <param name="ModuleId"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult EditFunction_Roles(string ModuleId)
        {
            return Ok(_app.EditFunction_Roles(ModuleId));
        }

        /// <summary>
        /// 修改（功能权限）
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public IActionResult UpdateFunction_Role(RoleAdministrator model)
        {
            return Ok(_app.UpdateFunction_Role(model));
        }

        /// <summary>
        /// 显示（角色权限设置）
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetRole()
        {
            return Ok(_app.GetRole());
        }

        /// <summary>
        /// 添加角色管理
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddRoless(int RoleId, string LoginId)
        {
            return Ok(_app.AddRoless(RoleId,LoginId));
        }

        /// <summary>
        /// 保存【添加角色管理】
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddInfos(Role_Login model)
        {
            return Ok(_app.AddInfos(model));
        }

        /// <summary>
        /// 显示用户
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetLogin()
        {
            return Ok(_app.GetLogin());
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult EditRole_Login(int RoleId)
        {
            return Ok(_app.EditRole_Login(RoleId));
        }

        /// <summary>
        /// 修改角色管理
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateRoless(int RoleId, string LoginId)
        {
            return Ok(_app.UpdateRoless(RoleId, LoginId));
        }
    }
}
